package com.example.frameboot.common;

import com.example.frameboot.been.CurrentUserInfo;
import lombok.Data;

/**
 * @author zhujy7@centaline.com.cn
 * @description 用户信息
 * @date 2020/3/30 16:27
 */
@Data
public class CurrentUserUtils {

    public static <T extends CurrentUserInfo> T transform(Class<T> clazz, Object src, CurrentUserInfo currentUserInfo) {
        if (src == null) {
            src = new Object();
        }
        T destinationObj = AutoMapper.transform(clazz, src);
        destinationObj.setCurrentEmpId(currentUserInfo.getCurrentEmpId());
        destinationObj.setCurrentEmpName(currentUserInfo.getCurrentEmpName());
        destinationObj.setCurrentEmpNo(currentUserInfo.getCurrentEmpNo());
        destinationObj.setCurrentDomainAccount(currentUserInfo.getCurrentDomainAccount());
        destinationObj.setCurrentPositionId(currentUserInfo.getCurrentPositionId());
        destinationObj.setCurrentPositionName(currentUserInfo.getCurrentPositionName());
        destinationObj.setCurrentOrgId(currentUserInfo.getCurrentOrgId());
        destinationObj.setCurrentOrgName(currentUserInfo.getCurrentOrgName());
        destinationObj.setCurrentOrgBelongTo(currentUserInfo.getCurrentOrgBelongTo());
        destinationObj.setCurrentPositionPrimary(currentUserInfo.isCurrentPositionPrimary());
        destinationObj.setCurrentPositionBelongTo(currentUserInfo.getCurrentPositionBelongTo());
        destinationObj.setTenantId(currentUserInfo.getTenantId());
        destinationObj.setTenantCode(currentUserInfo.getTenantCode());
        destinationObj.setCurrentOrgPath(currentUserInfo.getCurrentOrgPath());
        destinationObj.setIsAdmin(currentUserInfo.getIsAdmin());
        //当前登录角色ID
        destinationObj.setCurrentRoleId(currentUserInfo.getCurrentRoleId());
        destinationObj.setLoginDevice(currentUserInfo.getLoginDevice());
        destinationObj.setAppNo(currentUserInfo.getAppNo());
        return destinationObj;
    }


}
